// pages/Home/teacherT/teacherT.js
var businessLogic = require('../../../utils/NetWork/Model/HomebusinessLogic.js')
var common = require('../../../utils/common.js')
Page({
  
  /**
   * 页面的初始数据
   */
  data: {
    shaixuan:[
     /*  {
        "title": "全部",
        "select": 1
      },
      {
        "title": "初级教师",
        "select": 2
      },
      {
        "title": "中级教师",
        "select": 3
      },
      {
        "title": "高级教师",
        "select": 4
      },
      {
        "title": "特级教师",
        "select": 5
      }, */
    ],
    Select: 1,//判断是否选中
    teacherdetails:[],
    openPicker: false,
    needAnimation: false,
    num: 1,
    scrollHeight: 0,

    
  },
  //点击顶部导航
  choose: function (e) {
    common.showLoading("加载中", "loading");
    var that = this;
    that.setData({//把选中值放入判断值
      Select: e.currentTarget.dataset.select,  
    })
    let params = { "nowPage": 1, "pageSize": 1000, "orgid": this.data.orgid, "searchField": "orgid,level", "searchValue": ""+this.data.orgid+","+this.data.Select+"", "userid": this.data.userid }
    businessLogic.ListList(params, (res) => {
      var res = res.infos;
      this.setData({
        teacherdetails: res
      })
      common.hideLoading();
    });
  },
  teacherDetail: function (event) {
    //跳转
    wx.navigateTo({
      url: "../teacherDetail/teacherDetail?id=" + event.currentTarget.dataset.id
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var orgid = common.getStorageSync("orgid")
    var userid = common.getStorageSync("userid")
    var scrollHeight = scrollHeight;
    wx.getSystemInfo({
      success: function (res) {
        scrollHeight = res.windowHeight
      }
    });
    this.setData({
      orgid: orgid,
      userid: userid,
      scrollHeight: scrollHeight,
    });
    this.teacher(),
    this.teacherde()
    // console.log(orgid)
    
  },
  bindDownLoad: function () {
    if (this.data.lenpage > this.data.num) {
      var di = this.data.num;
      var di = di + 1;
      this.setData({
        num: di
      });
      console.log(di)
      this.teacherde();
    } else {
      common.showToast("加载全部", "loading");
    }
    //common.showToast("到底了", "loading");

  },

  //教师等级
  teacher: function () {
    let params = { "nowPage": 1, "pageSize": 1000, "pid": "c7031d04-f9b9-4e74-870f-0212cb11f04a", "orgid":this.data.orgid}
    businessLogic.ClassList(params, (res) => {
      this.setData({    
        shaixuan: res
      })
    });
  },
  //首次刷新全部
  teacherde: function () {
    common.showLoading("加载中", "loading");
    let params = { "nowPage": this.data.num, "pageSize": 10, "orgid": this.data.orgid, "searchField": "orgid", "searchValue": this.data.orgid,"userid":this.data.userid }
    businessLogic.ListList(params, (res) => {
      var page = res.page
      var res = res.infos;
      //第五步 把获取的值，传入data
      var bbb = this.data.teacherdetails
      for (let a = 0; a < res.length; a++) {
        bbb.push(res[a]);
      }
      this.setData({
        teacherdetails: bbb,
        lenpage: page.pages,
        Select:1
      })
      common.hideLoading();
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
 
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})